<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<f:view locale="#{salaoMB.internacionalizacao.currentLocale}">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<title>Configuração do horário de funcionamento</title>
	<script type="text/javascript">
function habilitar(value,ini,fim){ 

	var check = value.checked;
	var iniTime = document.getElementById(ini);
	var fimTime = document.getElementById(fim);

  if (check == true){    
	  iniTime.disabled = false; 
	  fimTime.disabled = false;
	  iniTime.style.backgroundColor='#FFFAFA';	
 	  fimTime.style.backgroundColor='#FFFAFA'; 
   }else{  
	  iniTime.disabled = true; 
	  fimTime.disabled = true; 
  	  iniTime.style.backgroundColor='#DCDCDC';	 
 	  fimTime.style.backgroundColor='#DCDCDC';	
  }            
}  
function formatar(src, mask){
	  var i = src.value.length;
	  var saida = mask.substring(0,1);
	  var texto = mask.substring(i);
	if (texto.substring(0,1) != saida)
	  {
	    src.value += texto.substring(0,1);
	  }
	}
	</script>
</h:head>
<h:body>

	<table width="100%">
		<tr>
			<td><ui:include src="/index.xhtml" /></td>
		</tr>
	</table>
	
	<f:metadata>
			<f:viewParam name="idEstabelecimento"
				value="#{funcionamentoEstabelecimentoMB.idSelectedEstabelecimento}"></f:viewParam>
			<f:event listener="#{configuracaoEstabelecimentoMB.buscarEstabelecimentosPorUsuario}"
				type="preRenderView" />
	</f:metadata>			

	<h:form id="configuracaoFuncionamentoEstabelecimento" prependId="false" >	

	<p:growl id="messagesCE" showDetail="true" sticky="true" />
	
		<table align="center">
			<tr>
				<td style="font-size: 15px;font-family: Arial; font-weight: bold;">Etapa 2 de 5</td>
				<td>&nbsp;</td>
			</tr>
		</table>	
	
		<table width="60%" align="center" >
			<tr>
				<td><p:panel header="Funcionamento do Estabelecimento" id="painelFuncionamentoEstabelecimento">

						<table width="100%">							
							<tr>								
								<td colspan="2">
								<h:outputText id="diasHorariosfuncionamento" value="Selecione os dias e os hor&aacute;rios de funcionamento da empresa: " />
								<br />
								</td>								
							</tr>
							<tr>
								<td>
								<h:panelGroup>
								    <h:outputText id="textEstabelecimento" value="Estabelecimento: " />
									<h:selectOneMenu value="#{funcionamentoEstabelecimentoMB.idSelectedEstabelecimento}" rendered="true" id="estabelecimento" immediate="true" >			
							 			<f:selectItem itemLabel="Selecione..." itemValue="0"/>	
							 			<f:selectItems value="#{funcionamentoEstabelecimentoMB.mapEstabelecimento}" var="estabelecimento" itemLabel="#{estabelecimento.nomeFantasia}" itemValue="{estabelecimento.id}" />							   		
						 			    <p:ajax update="tableDiaSemana" event="change" listener="#{funcionamentoEstabelecimentoMB.carregarHorarioDiaSemanaEstabelecimento}" />
						 			</h:selectOneMenu> 
							 		<p:commandLink id="btnFindConfigFuncionamentoEstab" update="tableDiaSemana" action="#{funcionamentoEstabelecimentoMB.carregarHorarioDiaSemanaEstabelecimento}" >
	                    				<p:graphicImage value="/img/find.gif" width="20" height="20"/>
	                    			</p:commandLink>	
                    			</h:panelGroup>
								</td>
							</tr>
							<tr>
								<td>
									<p:dataTable var="diaSemana" value="#{funcionamentoEstabelecimentoMB.listDiasSemana}" id="tableDiaSemana" emptyMessage="Selecione o estabelecimento para visualizar horários caso configirado.">  			
			
								        <p:column headerText="Segunda">  
								            <h:outputText value="#{diaSemana.horaIniSegunda} - #{diaSemana.horaFimSegunda}" />  
								        </p:column>  
								  
								        <p:column headerText="Terça">  
								            <h:outputText value="#{diaSemana.horaIniTerca} - #{diaSemana.horaFimTerca}" />    
								        </p:column>  
								  
								        <p:column headerText="Quarta">  
								            <h:outputText value="#{diaSemana.horaIniQuarta} - #{diaSemana.horaFimQuarta}" />   
								        </p:column>  
								  
								        <p:column headerText="Quinta">  
								            <h:outputText value="#{diaSemana.horaIniQuinta} - #{diaSemana.horaFimQuinta}" />   
								        </p:column>  
								        
								        <p:column headerText="Sexta">  
								            <h:outputText value="#{diaSemana.horaIniSexta} - #{diaSemana.horaFimSexta}" />   
								        </p:column>  
								        
								        <p:column headerText="Sábado">  
								            <h:outputText value="#{diaSemana.horaIniSabado} - #{diaSemana.horaFimSabado}" />   
								        </p:column>  
								        
								        <p:column headerText="Domingo">  
								            <h:outputText value="#{diaSemana.horaIniDomingo} - #{diaSemana.horaFimDomingo}" />   
								        </p:column>  
								        
								    </p:dataTable>
								</td>
							</tr>
						</table>

						<table width="100%" >
							<tr>
								<td>
									<table>
										<tr>
											<td>
												<!-- SEGUNDA  -->
												<table>
													<tr>
														<td><p:selectBooleanCheckbox
																value="#{funcionamentoEstabelecimentoMB.diaSemana.segunda}" onclick="habilitar(this,'horaIniSegunda_input','horaFimSegunda_input')"/>
														</td>
														<td><h:outputText value="SEGUNDA " />
														</td>
													</tr>

												</table>
											</td>
											<td>&nbsp;</td>
										</tr>
										<tr>
											<td>&nbsp;</td>
											<td>
												<table>
													<tr>
														<td colspan="2">Expediente:</td>
													</tr>
													<tr>
														<td><h:outputText value="Inicio " />
														</td>
														<td><h:inputText 
																value="#{funcionamentoEstabelecimentoMB.horaIniSegunda}"
																onkeypress="formatar(this,'##:##')"  maxlength="5" size="5" id="horaIniSegunda" />
														</td>
													</tr>
													<tr>
														<td><h:outputText value="Fim " /></td>
														<td><h:inputText
																value="#{funcionamentoEstabelecimentoMB.horaFimSegunda}"
																onkeypress="formatar(this,'##:##')"  maxlength="5" size="5"   id="horaFimSegunda"/>
														</td>
													</tr>
												</table></td>
										</tr>
										<tr>
											<td>
												<!-- TERCA  -->
												<table>
													<tr>
														<td><p:selectBooleanCheckbox
																value="#{funcionamentoEstabelecimentoMB.diaSemana.terca}" onchange="habilitar(this,'horaIniTerca_input','horaFimTerca_input')"/>
														</td>
														<td><h:outputText value="TER&Ccedil;A " />
														</td>
													</tr>

												</table>
											</td>
											<td>&nbsp;</td>
										</tr>
										<tr>
											<td>&nbsp;</td>
											<td>
												<table>
													<tr>
														<td colspan="2">Expediente:</td>
													</tr>
													<tr>
														<td><h:outputText value="Inicio " />
														</td>
														<td><h:inputText
																value="#{funcionamentoEstabelecimentoMB.horaIniTerca}"
																onkeypress="formatar(this,'##:##')"  maxlength="5" size="5"   id="horaIniTerca"/>
														</td>
													</tr>
													<tr>
														<td><h:outputText value="Fim " /></td>
														<td><h:inputText
																value="#{funcionamentoEstabelecimentoMB.horaFimTerca}"
																onkeypress="formatar(this,'##:##')"  maxlength="5" size="5"   id="horaFimTerca"/></td>
													</tr>
												</table>
											</td>
										</tr>
										<tr>
											<td>
												<!-- QUARTA  -->
												<table>
													<tr>
														<td><p:selectBooleanCheckbox
																value="#{funcionamentoEstabelecimentoMB.diaSemana.quarta}" onchange="habilitar(this,'horaIniQuarta_input','horaFimQuarta_input')"/>
														</td>
														<td><h:outputText value="QUARTA " />
														</td>
													</tr>

												</table>
											</td>
											<td>&nbsp;</td>
										</tr>
										<tr>
											<td>&nbsp;</td>
											<td>
												<table>
													<tr>
														<td colspan="2">Expediente:</td>
													</tr>
													<tr>
														<td><h:outputText value="Inicio " />
														</td>
														<td><h:inputText
																value="#{funcionamentoEstabelecimentoMB.horaIniQuarta}"
																onkeypress="formatar(this,'##:##')"  maxlength="5" size="5"   id="horaIniQuarta"/>
														</td>
													</tr>
													<tr>
														<td><h:outputText value="Fim " /></td>
														<td><h:inputText
																value="#{funcionamentoEstabelecimentoMB.horaFimQuarta}"
																onkeypress="formatar(this,'##:##')"  maxlength="5" size="5"   id="horaFimQuarta"/></td>
													</tr>
												</table></td>
										</tr>
										<tr>
											<td>
												<!-- QUINTA  -->
												<table>
													<tr>
														<td><p:selectBooleanCheckbox
																value="#{funcionamentoEstabelecimentoMB.diaSemana.quinta}" onchange="habilitar(this,'horaIniQuinta_input','horaFimQuinta_input')"/>
														</td>
														<td><h:outputText value="QUINTA " />
														</td>
													</tr>

												</table>
											</td>
											<td>&nbsp;</td>
										</tr>
										<tr>
											<td>&nbsp;</td>
											<td>
												<table>
													<tr>
														<td colspan="2">Expediente:</td>
													</tr>
													<tr>
														<td><h:outputText value="Inicio " />
														</td>
														<td><h:inputText
																value="#{funcionamentoEstabelecimentoMB.horaIniQuinta}"
																onkeypress="formatar(this,'##:##')"  maxlength="5" size="5"   id="horaIniQuinta"/>
														</td>
													</tr>
													<tr>
														<td><h:outputText value="Fim " /></td>
														<td><h:inputText
																value="#{funcionamentoEstabelecimentoMB.horaFimQuinta}"
																onkeypress="formatar(this,'##:##')"  maxlength="5" size="5"   id="horaFimQuinta"/></td>
													</tr>
												</table></td>
										</tr>
										<tr>
											<td>
												<!-- SEXTA  -->
												<table>
													<tr>
														<td><p:selectBooleanCheckbox
																value="#{funcionamentoEstabelecimentoMB.diaSemana.sexta}" onchange="habilitar(this,'horaIniSexta_input','horaFimSexta_input')"/>
														</td>
														<td><h:outputText value="SEXTA " />
														</td>
													</tr>

												</table>
											</td>
											<td>&nbsp;</td>
										</tr>
										<tr>
											<td>&nbsp;</td>
											<td>
												<table>
													<tr>
														<td colspan="2">Expediente:</td>
													</tr>
													<tr>
														<td><h:outputText value="Inicio " />
														</td>
														<td><h:inputText
																value="#{funcionamentoEstabelecimentoMB.horaIniSexta}"
																onkeypress="formatar(this,'##:##')"  maxlength="5" size="5"   id="horaIniSexta"/>
														</td>
													</tr>
													<tr>
														<td><h:outputText value="Fim " /></td>
														<td><h:inputText
																value="#{funcionamentoEstabelecimentoMB.horaFimSexta}"
																onkeypress="formatar(this,'##:##')"  maxlength="5" size="5"   id="horaFimSexta"/>
														</td>
													</tr>
												</table></td>
										</tr>
										<tr>
											<td>
												<!-- S&Aacute;BADO  -->
												<table>
													<tr>
														<td><p:selectBooleanCheckbox
																value="#{funcionamentoEstabelecimentoMB.diaSemana.sabado}" onchange="habilitar(this,'horaIniSabado_input','horaFimSabado_input')"/>
														</td>
														<td><h:outputText value="S&Aacute;BADO " />
														</td>
													</tr>

												</table>
											</td>
											<td>&nbsp;</td>
										</tr>
										<tr>
											<td>&nbsp;</td>
											<td>
												<table>
													<tr>
														<td colspan="2">Expediente:</td>
													</tr>
													<tr>
														<td><h:outputText value="Inicio " />
														</td>
														<td><h:inputText
																value="#{funcionamentoEstabelecimentoMB.horaIniSabado}"
																onkeypress="formatar(this,'##:##')"  maxlength="5" size="5"   id="horaIniSabado"/>
														</td>
													</tr>
													<tr>
														<td><h:outputText value="Fim " /></td>
														<td><h:inputText
																value="#{funcionamentoEstabelecimentoMB.horaFimSabado}"
																onkeypress="formatar(this,'##:##')"  maxlength="5" size="5"   id="horaFimSabado"/>
														</td>
													</tr>
												</table>
											</td>
										</tr>
										<tr>
											<td>
												<!-- DOMINGO  -->
												<table border="0">
													<tr>
														<td><p:selectBooleanCheckbox
																value="#{funcionamentoEstabelecimentoMB.diaSemana.domingo}" onchange="habilitar(this,'horaIniDomingo_input','horaFimDomingo_input')"/>
														</td>
														<td><h:outputText value="DOMINGO " />
														</td>
													</tr>

												</table>
											</td>
											<td>&nbsp;</td>
										</tr>
										<tr>
											<td>&nbsp;</td>
											<td>
												<table>
													<tr>
														<td colspan="2">Expediente:</td>
													</tr>
													<tr>
														<td><h:outputText value="Inicio " />
														</td>
														<td><h:inputText
																value="#{funcionamentoEstabelecimentoMB.horaIniDomingo}"
																onkeypress="formatar(this,'##:##')"  maxlength="5" size="5"   id="horaIniDomingo"/>
														</td>
													</tr>
													<tr>
														<td><h:outputText value="Fim " /></td>
														<td><h:inputText
																value="#{funcionamentoEstabelecimentoMB.horaFimDomingo}"
																onkeypress="formatar(this,'##:##')"  maxlength="5" size="5"  id="horaFimDomingo"/>
														</td>
													</tr>
												</table></td>
										</tr>
									</table>
								</td>
							</tr>							
						</table>
						<table width="100%">
							<tr>
								<td align="right"><h:commandButton type="reset" value="#{msg.limpar}" />
								</td>
								<td align="left"><h:commandButton type="submit" actionListener="#{funcionamentoEstabelecimentoMB.configurar}" value="#{msg.gravar}"/></td>
								
							</tr>
						</table>
					</p:panel></td>
			</tr>
		</table>
		

	</h:form>
</h:body>
</f:view>
</html>